C MICROSOFT FORTRAN - OPT-TECH SORT RECORD AT A TIME SAMPLE
      CHARACTER*70 INBUF
      INTEGER*2 FUNC, INLEN, RETCODE
      OPEN (3,FILE='SAMP.DAT',STATUS='OLD',ACCESS='SEQUENTIAL',
     X FORM='FORMATTED')

C PASS CONTROL STATEMENT TO INITIALIZE, FUNC=1
      FUNC = 1
      INBUF = 'S(1,10,C,A)'
      INLEN = 11
      CALL RSMSF(FUNC,INBUF,INLEN,RETCODE)
      IF (RETCODE.NE.0) GOTO 900

C PASS RECORDS TO SORT ONE AT A TIME, FUNC=2
      INLEN = 70
      FUNC = 2
  200 READ(3,5000,END=300) INBUF
      CALL RSMSF(FUNC,INBUF,INLEN,RETCODE)
      IF (RETCODE.NE.0) GOTO 900
      GOTO 200

C RETRIEVE RECORDS FROM SORT ONE AT A TIME, FUNC=3
  300 FUNC = 3
      CALL RSMSF(FUNC,INBUF,INLEN,RETCODE)
      IF (RETCODE.EQ.1) GOTO 400
      IF (RETCODE.NE.0) GOTO 900
      WRITE(*,*) INBUF
      GOTO 300

C END OF JOB
  400 WRITE(*,5002)
      STOP

C ERROR HANDLING
  900 WRITE(*,5003) RETCODE
      STOP
 5000 FORMAT(A)
 5002 FORMAT(1X,'Record At A Time Opt-Tech Sort Completed')
 5003 FORMAT(1X,'RETCODE ='i4)
      END


